﻿@model List<Mondial2014.Models.Competition.Team>

@{
    ViewBag.Title = "עידכון עולות";
}

<h2>עידכון עולות</h2>

@Html.ActionLink("חזרה לרשימת עולות", "Index", "Qualifiers")
<br/><br />

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">

        <div class="form-group">
            <input type="submit" value="שמור" class="btn btn-default" />
        </div>

        <table class="table">
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.First().Name)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.First().Last16)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.First().Quarter)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.First().Semi)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.First().Final)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.First().Winner)
                </th>
            </tr>


            @for (var index = 0; index < Model.Count(); index++)
            {
                <tr>
                    <td>
                        @Html.TextBox("teams[" + @index + "].Id", Model[index].Id, new { @readonly = "readonly", @style = "display:none" })
                        @Html.TextBox("teams[" + @index + "].Name", Model[index].Name, new { @readonly = "readonly", @style = "display:none" })
                        @Html.DisplayFor(modelItem => Model[index].Name)
                    </td>
                    <td>
                        @{ var qualified = Model[index].Last16; }
                        @Html.DropDownList("teams[" + @index + "].Last16", new[] { new SelectListItem { Text = "לא", Value = "false", Selected = !qualified }, new SelectListItem { Text = "כן", Value = "true", Selected = qualified } })
                    </td>
                    <td>
                        @{ qualified = Model[index].Quarter; }
                        @Html.DropDownList("teams[" + @index + "].Quarter", new[] { new SelectListItem { Text = "לא", Value = "false", Selected = !qualified }, new SelectListItem { Text = "כן", Value = "true", Selected = qualified } })
                    </td>
                    <td>
                        @{ qualified = Model[index].Semi; }
                        @Html.DropDownList("teams[" + @index + "].Semi", new[] { new SelectListItem { Text = "לא", Value = "false", Selected = !qualified }, new SelectListItem { Text = "כן", Value = "true", Selected = qualified } })
                    </td>
                    <td>
                        @{ qualified = Model[index].Final; }
                        @Html.DropDownList("teams[" + @index + "].Final", new[] { new SelectListItem { Text = "לא", Value = "false", Selected = !qualified }, new SelectListItem { Text = "כן", Value = "true", Selected = qualified } })
                    </td>
                    <td>
                        @{ qualified = Model[index].Winner; }
                        @Html.DropDownList("teams[" + @index + "].Winner", new[] { new SelectListItem { Text = "לא", Value = "false", Selected = !qualified }, new SelectListItem { Text = "כן", Value = "true", Selected = qualified } })
                    </td>
                </tr>
            }

        </table>

        <div class="form-group">
            <input type="submit" value="שמור" class="btn btn-default" />
        </div>

    </div>
}

<div>
    <br />
    @Html.ActionLink("חזרה לרשימת עולות", "Index", "Qualifiers")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}